/**
 * @Author: MN
 * @Date: 2023-07-28 14:02:38
 * @LastEditTime: 2023-08-22 18:06:41
 * @LastEditors: MN
 * @Description: ''
 * @FilePath: \vue2-element-admin-simple-diy\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/home'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login')
  },
  {
    path: '/',
    name: 'home',
    component: HomeView
  }
]

const createRouter = () => new VueRouter({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: routes
})

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

const router = createRouter()

export default router
